package demo.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.ximalaya.xdcs.spring.filter.XmlyXdcsTraceFilter;
import com.ximalaya.xdcs.spring.healthcheck.HealthcheckServlet;

@Configuration
public class ServletConfig {
    @Bean
    public ServletRegistrationBean healthCheckServletServlet() {
        return new ServletRegistrationBean(new HealthcheckServlet(), "/openapi-clearing-sync/healthcheck");
    }

    @Bean
    public FilterRegistrationBean xdcsTraceFilterFilter() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new XmlyXdcsTraceFilter());
        registration.addUrlPatterns("/*");
        registration.setName("springTraceFilter");
        registration.setOrder(1);
        return registration;
    }

}
